package com.design.behavior.visitor.cainiao;

/**
 * @ProjectName: design
 * @Package: com.design.behavior.visitor.cainiao
 * @ClassName: Computer
 * @Author: shenaiguo
 * @Description:
 * @Date: 2020/11/15 0015 9:49
 */
// 步骤2
public class Computer implements  ComputerPart{
    ComputerPart[] parts;

    public Computer(){
        parts = new ComputerPart[] {new Mouse(), new Keyboard(), new Monitor()};
    }


    @Override
    public void accept(ComputerPartVisitor computerPartVisitor) {
        for (int i = 0; i < parts.length; i++) {
            parts[i].accept(computerPartVisitor);
        }
        computerPartVisitor.visit(this);
    }
}
